import type {PageParam, PageResult} from '@vben/request';
import type {Dayjs} from 'dayjs';

import {requestClient} from '#/api/request';
export namespace PerVehicleInfoApi {
  /** 人员车辆情况信息 */
  export interface VehicleInfo {
    id: number; // 主键ID
    employeeId?: number; // 人员ID，对应 per_employee.id
    personalIdcard: string; // 个人身份证号
    purchaseDate: string | Dayjs; // 购车时间
    purchasePrice: number; // 购车价格
    brandModel: string; // 品牌型号
    plateNumber: string; // 车辆号牌
    status: number; // 记录状态（1：有效，0：无效）
    remarks: string; // 备注
  }
}

/** 查询人员车辆情况分页 */
export function getVehicleInfoPage(data: PageParam,desensitize: boolean,encrypt: boolean) {
  return requestClient.post<PageResult<PerVehicleInfoApi.VehicleInfo>>('/per/vehicle-info/page', data,{ desensitize,encrypt });
}

/** 查询人员车辆情况详情 */
export function getVehicleInfo(id: number) {
  return requestClient.get<PerVehicleInfoApi.VehicleInfo>(`/per/vehicle-info/get?id=${id}`);
}

/** 新增人员车辆情况 */
export function createVehicleInfo(data: PerVehicleInfoApi.VehicleInfo) {
  return requestClient.post('/per/vehicle-info/create', data);
}

/** 修改人员车辆情况 */
export function updateVehicleInfo(data: PerVehicleInfoApi.VehicleInfo) {
  return requestClient.put('/per/vehicle-info/update', data);
}

/** 删除人员车辆情况 */
export function deleteVehicleInfo(id: number) {
  return requestClient.delete(`/per/vehicle-info/delete?id=${id}`);
}

/** 批量删除人员车辆情况 */
export function deleteVehicleInfoList(ids: number[]) {
  return requestClient.delete(`/per/vehicle-info/delete-list?ids=${ids.join(',')}`)
}

/** 导出人员车辆情况 */
export function exportVehicleInfo(params: any) {
  return requestClient.download('/per/vehicle-info/export-excel', { params });
}

/** 获取当前登录人车辆信息 */
export function getCurrentVehicleInfos(
  data,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<
    List<PerVehicleInfoApi.VehicleInfo>
  >('/per/vehicle-info/getCurrentVehicleInfos', data, {
    desensitize,
    encrypt,
  });
}